import { defineStore } from "pinia";
import { Entry } from "@/types/intro";

export default defineStore("entry", {
    state: () => ({
        entries: [] as Entry[],
        entryLoaded: false,
    }),
    getters: {
        getEntryLoaded: (state) => state.entryLoaded,
        getEntryByTitle: (state) => (title: string) => {
            return state.entries.find((item) => item.title === title);
        },
        getOrdinaryEntries: (state) =>
            state.entries.filter(
                (item) => item.title !== "模型介绍" && item.title !== "简介"
            ),
    },
    actions: {
        setEntries(entries: Entry[]) {
            this.entries = entries;
            this.entryLoaded = true;
        },
    },
});
